﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Configuration;
using MDF.Logger.Interfaces;
using MDF.Logger.Implements;

namespace MDF.Logger.Managements
{
    public class LogManager
    {
        private static ILog m_log = null;
        private static string m_setting=null;
        private static object keylock = new object();
        private LogManager()
        {
            Init();
        }
        public static ILog GetInstance()
        {
            Init();
            return m_log;
        }
        private static void Init()
        {
            lock (keylock)
            {
                if (m_log == null)
                {
                    if (m_setting == null)
                    {
                        m_setting = ConfigurationManager.AppSettings["LogType"];
                        if (string.IsNullOrEmpty(m_setting))
                            m_setting = "File";
                    }
                    switch (m_setting)
                    {
                        
                        case "File":
                            m_log = new FileLogger();
                            break;
                        default:
                            m_log = new FileLogger();
                            break;
                    }
                }
            }
        }
    }
}
